package com.bah.tract.client.ui;

import java.util.HashMap;
import java.util.Map;

import javax.swing.table.TableCellEditor;
import javax.swing.table.TableCellRenderer;

public class TaskTable extends javax.swing.JTable {
	/**
			 * 
			 */
	private static final long serialVersionUID = 5540781481727558099L;

	@Override
	public final boolean isCellEditable(final int row, final int column) {
		return column == 2;
	}

	@Override
	public final int getRowHeight() {
		return 20;
	}

	@Override
	public final TableCellRenderer getCellRenderer(final int row, final int column) {
		if ((column == 2) && taskRenderers.containsKey(row)) {
			return taskRenderers.get(row);
		}
		return super.getCellRenderer(row, column);
	}

	@Override
	public final TableCellEditor getCellEditor(final int row, final int column) {
		if ((column == 2) && taskRenderers.containsKey(row)) {
			return taskEditors.get(row);
		}
		return super.getCellEditor(row, column);
	}

	private final Map<Integer, TableCellRenderer> taskRenderers = new HashMap<Integer, TableCellRenderer>();
	private final Map<Integer, TableCellEditor> taskEditors = new HashMap<Integer, TableCellEditor>();

	public final void setTaskRenderer(final int row, final TableCellRenderer renderer) {
		taskRenderers.put(row, renderer);
	}

	public final void setTaskEditor(final int row, final TableCellEditor renderer) {
		taskEditors.put(row, renderer);
	}

}